package Algorithm.Array;

class Supermarket {
    private Fruit apple;
    private Fruit strawberry;
    private Fruit mango;

    public Supermarket() {
        apple = new Fruit("苹果", 8.0);
        strawberry = new Fruit("草莓", 13.0);
        mango = new Fruit("芒果", 20.0);
    }

    // 顾客 A
    public double calculateTotalPriceForCustomerA(int appleWeight, int strawberryWeight) {
        return (apple.getPricePerJin() * appleWeight) + (strawberry.getPricePerJin() * strawberryWeight);
    }

    // 顾客 B
    public double calculateTotalPriceForCustomerB(int appleWeight, int strawberryWeight, int mangoWeight) {
        return (apple.getPricePerJin() * appleWeight) + 
               (strawberry.getPricePerJin() * strawberryWeight) + 
               (mango.getPricePerJin() * mangoWeight);
    }

    // 顾客 C
    public double calculateTotalPriceForCustomerC(int appleWeight, int strawberryWeight, int mangoWeight) {
        double total = 0.0;
        total += (apple.getPricePerJin() * appleWeight);
        total += (strawberry.getPricePerJin() * 0.8 * strawberryWeight); // 草莓 8 折
        total += (mango.getPricePerJin() * mangoWeight);
        return total;
    }

    // 顾客 D
    public double calculateTotalPriceForCustomerD(int appleWeight, int strawberryWeight, int mangoWeight) {
        double total = 0.0;
        total += (apple.getPricePerJin() * appleWeight);
        total += (strawberry.getPricePerJin() * 0.8 * strawberryWeight); // 草莓 8 折
        total += (mango.getPricePerJin() * mangoWeight);

        if (total >= 100) {
            total -= 10; // 满 100 减 10
        }

        return total;
    }
}

class Fruit {
    private String name;
    private double pricePerJin;

    public Fruit(String name, double pricePerJin) {
        this.name = name;
        this.pricePerJin = pricePerJin;
    }

    public String getName() {
        return name;
    }

    public double getPricePerJin() {
        return pricePerJin;
    }

    public void setPricePerJin(double pricePerJin) {
        this.pricePerJin = pricePerJin;
    }
}

class Main {
    public static void main(String[] args) {
        Supermarket supermarket = new Supermarket();

        // 顾客 A
        int appleWeightA = 2;
        int strawberryWeightA = 3;
        double totalPriceA = supermarket.calculateTotalPriceForCustomerA(appleWeightA, strawberryWeightA);
        System.out.println("顾客 A 的总价: " + totalPriceA);

        // 顾客 B
        int appleWeightB = 4;
        int strawberryWeightB = 5;
        int mangoWeightB = 1;
        double totalPriceB = supermarket.calculateTotalPriceForCustomerB(appleWeightB, strawberryWeightB, mangoWeightB);
        System.out.println("顾客 B 的总价: " + totalPriceB);

        // 顾客 C
        int appleWeightC = 4;
        int strawberryWeightC = 5;
        int mangoWeightC = 1;
        double totalPriceC = supermarket.calculateTotalPriceForCustomerC(appleWeightC, strawberryWeightC, mangoWeightC);
        System.out.println("顾客 C 的总价: " + totalPriceC);

        // 顾客 D
        int appleWeightD = 4;
        int strawberryWeightD = 5;
        int mangoWeightD = 1;
        double totalPriceD = supermarket.calculateTotalPriceForCustomerD(appleWeightD, strawberryWeightD, mangoWeightD);
        System.out.println("顾客 D 的总价: " + totalPriceD);
    }
}